#include<bits/stdc++.h>
using namespace std;
int a[200001],b[5],n,c[5];
int main()
{
	freopen("fen.in","r",stdin);
	freopen("fen.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]=b[a[i]]+1;
	}
	c[2]=b[1];
	c[3]=b[2]+b[1];
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			c[3]=c[3]-1;
			c[2]=c[2]-1;
			cout<<0<<" ";
		}
		else if(a[i]==2)
		{
			c[3]=c[3]-1;
			cout<<c[2]<<" ";
		}
		else if(a[i]==3)
		{
			cout<<c[3]<<" ";
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
